using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace SIAIllustrator.Calculator
{
    [Serializable]
    public class Scenario
    {

        #region member variables
        int scenarioID;
        double premium;
        String type;
        int month;       
        int beginYear, endYear;
        int deferralPeriod, payoutPeriod;
        double deferralParticipationRate, payoutParticipationRate, guaranteedRate;
        bool enabled = true;
        DataTable dtPayout; 
        
 
        private static int scenarioIDCount = 0;
        public static String PeriodCertain = "Period Certain";
        public static String LumpSum = "Lump Sum";
        #endregion

        public Scenario()
        { }

        public Scenario(double premium, String type, int month, int beginYear, int endYear,
            int deferralPeriod, int payoutPeriod, double deferralParticipationRate,
            double payoutParticipationRate, double guaranteedRate)
        {
            this.scenarioID = scenarioIDCount;
            scenarioIDCount++;

            this.premium = premium;
            this.type = type;
            this.month = month;
            this.beginYear = beginYear;
            this.endYear = endYear;
            this.deferralPeriod = deferralPeriod;
            this.payoutPeriod = payoutPeriod;
            this.deferralParticipationRate = deferralParticipationRate;
            this.payoutParticipationRate = payoutParticipationRate;
            this.guaranteedRate = guaranteedRate;
        }

        public int ScenarioID
        {
            get { return scenarioID; }
            set { scenarioID = value; }
        }

        public double Premium
        {
            get { return premium; }
            set { premium = value; }
        }

        public String Type
        {
            get { return type; }
            set { type = value; }
        }

        public int BeginYear
        {
            get { return beginYear; }
            set { beginYear = value; }
        }

        public int EndYear
        {
            get { return endYear; }
            set { endYear = value; }
        }

        public int DeferralPeriod
        {
            get { return deferralPeriod; }
            set { deferralPeriod = value; }
        }

        public int PayoutPeriod
        {
            get { return payoutPeriod; }
            set { payoutPeriod = value; }
        }
        
        public double DeferralParticipationRate
        {
            get { return deferralParticipationRate; }
            set { deferralParticipationRate = value; }
        }

        public double PayoutParticipationRate
        {
            get { return payoutParticipationRate; }
            set { payoutParticipationRate = value; }
        }

        public double GuaranteedRate
        {
            get { return guaranteedRate; }
            set { guaranteedRate = value; }
        }

        public bool Enabled
        {
            get { return enabled; }
            set { enabled = value; }
        }

        public int Month
        {
            get { return month; }
            set { month = value; }
        }

        public DataTable Payout
        {
            get { return dtPayout; }
            set { dtPayout = value; }
        }

        public void Calculate(DataTable dtIndex)
        {

            int ptype = 0;
            if (type == "Period Certain")
                ptype = 1;
            else
                ptype = 2;


            DataTable dtPayout = IndexCalculator.CalculateAnnuity(premium, month, beginYear, 
                endYear, deferralParticipationRate, payoutParticipationRate, 
                guaranteedRate, .00000000001, deferralPeriod, payoutPeriod, ptype, dtIndex);

            this.dtPayout = dtPayout;

        }
    }
}
